@extends('backend.layouts.app')

@section('title', $title ='添加查看' )

@section('breadcrumb')
    <a href="">系统设置</a>
    <a href="">网站管理</a>
    <a href="">{{$title}}</a>
@endsection

@section('content')
    <div class="layui-main">

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>{{ $title }}</legend>
        </fieldset>
        <form class="layui-form" action="">
            <div class="layui-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">网站显示名</label>
                    <div class="layui-input-block">
                        <input type="text" name="site_name" required lay-verify="required" placeholder="请输入网站显示名"
                               autocomplete="off" class="layui-input" value="{{ old('site_name',$site->site_name) }}"
                               @if($site->id) disabled @endif>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">网站名</label>
                    <div class="layui-input-block">
                        <input type="text" name="username" required lay-verify="required" placeholder="请输入网站名"
                               autocomplete="off" class="layui-input" value="{{ old('username',$site->username) }}"
                               @if($site->id) disabled @endif>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">外部网站</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_external" value="1" title="是" @if($site->is_external) checked
                               @endif disabled>
                        <input type="radio" name="is_external" value="0" title="否" @if(!$site->is_external) checked
                               @endif disabled>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">启用</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="是" @if($site->status) checked
                               @endif disabled>
                        <input type="radio" name="status" value="0" title="否" @if(!$site->status) checked
                               @endif disabled>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">网站帐号</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" required lay-verify="required" placeholder="请输入网站帐号"
                               autocomplete="off" class="layui-input" value="{{ old('username',$site->username) }}"
                               disabled>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">网站key</label>
                    <div class="layui-input-block">
                        <input type="text" name="token" lay-verify="" placeholder=""
                               autocomplete="off" class="layui-input" value="{{ old('token',$site->token) }}"
                               disabled>
                    </div>
                </div>

                <div class="layui-form-item " pane="">
                    <label class="layui-form-label">平台</label>
                    @foreach($plats as $key => $val)
                        <div class="layui-input-block layui-row">
                            <div class="layui-col-xs4">
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="plats[id][]" lay-skin="primary"
                                           value="{{ $val['id'] }}"
                                           title="{{ $val['main_game_plat_name'] }}"
                                           checked="" disabled>
                                </div>
                            </div>
                            <div class=" layui-col-xs4">
                                <div class="layui-input-inline">
                                    <input type="text" name="plats[rate][]"
                                           placeholder="比率"
                                           value="{{$val['pivot']['rate']}}"
                                           disabled autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-xs4">
                                <div class="layui-input-inline">
                                    <input type="text" name="plats[rate][]"
                                           placeholder="平台分数"
                                           value="{{$val['pivot']['score']}}"
                                           disabled autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>

                    @endforeach
                </div>

                <div class="layui-form-item">
                    <a href="#" class="layui-btn" onclick="javascript:history.back(-1);" lay-filter="demo1">返回</a>
                </div>

            </div>
        </form>

    </div>
@endsection

@section('scripts')
    <script>
        layui.use('form', function () {
            var form = layui.form;

            form.verify({
                rate: [
                    /^0\.\d{1,3}/
                    , '比率必须大于等于0保留两位小数，并且小于1，'
                ]
            });
        });

    </script>
@endsection